package com.siren.tank;

import com.siren.test.ImageTest;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 * @author : wangjichao
 * @description:
 * @date : 2020/7/27 13:21
 */
public class ResourceMgr {
    public static BufferedImage tankL, tankR, tankU, tankD;
    public static BufferedImage bulletL, bulletR, bulletU, bulletD;
    public static BufferedImage[] explodes = new BufferedImage[16];

    static {
        tankL = getImage("images/tankL.gif");
        tankR = getImage("images/tankR.gif");
        tankU = getImage("images/tankU.gif");
        tankD = getImage("images/tankD.gif");
        bulletL = getImage("images/bulletL.gif");
        bulletR = getImage("images/bulletR.gif");
        bulletU = getImage("images/bulletU.gif");
        bulletD = getImage("images/bulletD.gif");

        for (int i = 0; i < 16; i++) {
            explodes[i] = getImage("images/e" + (i+1) + ".gif");
        }
    }

    private static BufferedImage getImage(String imagePath) {
        BufferedImage read = null;
        try {
            read = ImageIO.read(ImageTest.class.getClassLoader().getResourceAsStream(imagePath));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return read;
    }
}
